package com.ce.pms.renovation.dao.impl;

import java.util.List;

import org.hibernate.Query;

import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.renovation.dao.IReformDao;
import com.ce.pms.renovation.model.ReformDO;

/**
*
* 功能描述: 整改记录DAO ReformDaoImpl
* <p>版权所有：中企动力
* <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
*
* @author  许心炜
* Created on：  2008-12-19
* @author  许心炜
* update on：  2008-12-19
*/

public class ReformDaoImpl extends PmsBaseDaoImpl<ReformDO> implements IReformDao{

	/**获得整改记录列表
	 * @author  许心炜
	 *@param	renovateViolationId
	 *@return 	Page
	 */
	public List<ReformDO> getReforms(Long renovateViolationId) {
		String hql = "from ReformDO r where r.renovateViolationDO.keyword = ? ";
		Query query = this.createQuery(hql, renovateViolationId);
		List<ReformDO> list = query.list();
		return  list;
	}

	/**
	 *获得整改记录DO
	 *@author  许心炜
	 *@param 	reformId
	 *@return	ReformDO
	 */
	public ReformDO getReform(Long reformId) {
		String hql = "from ReformDO r where r.keyword = ? ";
		Query query = this.createQuery(hql, reformId);
		List<ReformDO> list = query.list();
		if(list.size() > 0) {
			return  list.get(0);
		}else {
			return null;
		}
	}

	/**
	 *获得通过的整改记录
	 *@author  许心炜
	 *@param 	renovateViolationId
	 *@return	ReformDO
	 */
	public ReformDO getPassReform(Long renovateViolationId) {
		String hql = "from ReformDO r where r.renovateViolationDO.keyword = ? and r.result = '001'";
		Query query = this.createQuery(hql, renovateViolationId);
		List<ReformDO> list = query.list();
		if(list.size() > 0) {
			return  list.get(0);
		}else {
			return null;
		}
	}


}
